<?php
//把留言写到数据库里去
session_start();
$Art_id=$_GET['Art_id'];
$R_name=$_POST['R_name'];
$R_email=$_POST['R_email'];
$R_Data=getdate();
$R_content=$_POST['R_content'];
if($R_name=="" || $R_content=="")
{
    echo "<script>alert('姓名或留言不能为空!!'); window.location.href='../artview.php?Art_id=".$Art_id."';</script>";
}
else
{
 function addr($Art_id,$R_name,$R_email,$R_Data,$R_content)
{
require_once("conn.php");
    $sql_insert="insert into artr (Art_id,R_Data,R_name,R_email,R_content)values('$Art_id',NOW(),'$R_name','$R_email','$R_content');";
    $sql_addr_num="UPDATE  artcontent SET rnum=rnum+1 WHERE Art_id='$Art_id'";
    if(mysql_query($sql_insert) && mysql_query($sql_addr_num)) 
    echo "<script>alert('添加留言成功!!'); window.location.href='../artview.php?Art_id=".$Art_id."';</script>";   
}
addr($Art_id,$R_name,$R_email,$R_Data,$R_content);
}

?>